﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Threading;
using System.ComponentModel;

namespace NetwerkScanner
{
    public class BasicServiceSet : INotifyPropertyChanged
    {

        public string MACAddress { get; set; }
        public string SSID { get; set; }
        public int RSSI { get; set; }
        public DateTime EerstGezien { get; set; }
        public DateTime LastUpdate { get; set; }

        public BasicServiceSet(string networkName, int p, string p_2)
        {
            SSID = networkName;
            RSSI = p;
            MACAddress = p_2;
            EerstGezien = DateTime.Now;
            LastUpdate = DateTime.Now;
        }

        public void Update(BasicServiceSet bss)
        {
            LastUpdate = DateTime.Now;
            RSSI = bss.RSSI;
            ChangeProperty("LastUpdate");
            ChangeProperty("RSSI");
            ExtendedServiceSet ess = App.Applicatie.ExtendedServiceSets.FirstOrDefault(n => n.SSID == SSID);
            if (ess != null)
            {
                ess.ChangeProperty("RSSI");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void ChangeProperty(string s)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(s));
            }
        }

    }
}
